package com.sanbi.common.vo;

import com.sanbi.common.util.FileUtil;

public class Enums {
    /**
     * @desc 文件类型
     * @author wanggang
     * @time 2022/7/18 10:31
     */
    public enum FileType {
        Jpg(1, "image/jpeg","image"),
        Png(2,"image/png","image"),
        Gif(3, "image/gif","image"),
        Bmp(4, "image/bmp","image"),
        Webp(5, "image/webp","image"),
        NotImage(415,"NotImage","NotImage");

        private int code;
        private String contentType;
        private String type;

        FileType(int code,String contentType,String type) {
            this.code=code;
            this.contentType=contentType;
            this.type = type;
        }

        public int getCode() {
            return code;
        }

        public String getContentType() {
            return contentType;
        }

        public String getType() {
            return type;
        }

        public static FileType getItem(String contentType){
            for (FileType item: FileType.values()) {
                if(item.getContentType().equals(contentType)){
                    return item;
                }
            }

            return FileType.NotImage;
        }
    }

    /**
     * @desc token类型枚举
     * @author wanggang
     * @time 2024/10/15 13:37
     */
    public enum TokenTypeEnum {
        ClientToken("day",180,"client-token"),
        SaleToken("day", 1,"sale-token"),
        WareToken("day", 1,"ware-token");

        //过期时间单位
        private String expiredTimeUnit;
        //过期时间
        private int expiredTime;
        //token类型说明
        private String desc;

        TokenTypeEnum(String expiredTimeUnit,int expiredTime,String desc) {
            this.expiredTimeUnit=expiredTimeUnit;
            this.expiredTime=expiredTime;
            this.desc = desc;
        }

        public String getExpiredTimeUnit() {
            return expiredTimeUnit;
        }

        public int getExpiredTime() {
            return expiredTime;
        }

        public String getDesc() {
            return desc;
        }

    }

    /**
     * @desc 文件名的类型
     * @author wanggang
     * @time 2024/3/13 16:21
     */
    public enum FilenameType {
        Random(1, "随机名称"),
        OriginAndRandom(2,"源文件名+随机数"),
        Origin(3, "源文件名"),
        Undefiled(1, "未指定");

        private int type;
        private String desc;

        FilenameType(int type, String desc) {
            this.type = type;
            this.desc=desc;
        }

        public String getDesc() {
            return desc;
        }

        public int getType() {
            return type;
        }

        public static FilenameType getItem(int type){
            for (FilenameType item: FilenameType.values()) {
                if(item.getType()==type){
                    return item;
                }
            }

            return FilenameType.Undefiled;
        }
    }

    public static void main(String[] args) {
        boolean isImage= FileUtil.isImageFile(FileType.getItem("image/png"));
        System.out.println(isImage);
    }
}
